﻿using DevExpress.XtraGrid.Demos.util;
using DiaoPaiDaYin;
using DXApplicationTangche.DTO;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.订单一览新.辅料.service;
using DXApplicationTangche.UC.销售管理;
using DXApplicationTangche.UC.销售记录.service;
using DXApplicationTangche.UC.门店下单.DTO;
using DXApplicationTangche.UC.门店下单.service;
using mendian;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.订单一览新.订单预览新.service
{
    public class 订单预览新Service
    {
        /// <summary>
        /// 更新订单尺寸数据
        /// </summary>
        /// <param name="orderCommitDTO"></param>
        /// <returns></returns>
        public static String updateOrderCommitSizeAndMeasureItems(OrderCommitDTO返回 orderCommitDTO)
        {
            return
                RestCall.PostHttp(
                        URL.接口url + "/barcode/updateOrderCommitSizeAndMeasureItems?orderId=" + orderCommitDTO.orderId 
                        + "&styleSizeCd=" + orderCommitDTO.styleSizeCd 
                        + "&sessionId=" + orderCommitDTO.sessionId,
                        FunctionHelper.JsonSerialization(orderCommitDTO.measureItemDTOS)
                        );
        }
        /// <summary>
        /// 由成衣条码查询orderCommitDTO
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static OrderCommitDTO返回 getOrderCommitDTOByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<OrderCommitDTO返回>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/garment/getOrderCommitDtoByBarcode?barcode=" + barcode
                        )
                    );
        }
        /// <summary>
        /// 由订单id查询orderCommitDTO
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public static OrderCommitDTO返回 get订单预览(String orderId)
        {
            return
                FunctionHelper.JsonDeserialization<OrderCommitDTO返回>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/getOrderCacheByOrderId?orderId=" + orderId
                        )
                    );
        }
        /// <summary>
        /// 根据电话取返单
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static List<OrderCommitDTO返回> getOrderCommitsByMoblie(String mobile)
        {
            return
                FunctionHelper.JsonDeserialization<List<OrderCommitDTO返回>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/customer/getOrderCommitsByMoblie?mobile=" + mobile
                        )
                    );
        }
        
        /// <summary>
        /// 根据电话取返单，这是最新的
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public static List<OrderCommitDTO返回> getHistoryOrderCommitByMobile(String mobile)
        {
            return
                FunctionHelper.JsonDeserialization<List<OrderCommitDTO返回>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/customer/getHistoryOrderCommitByMobile?mobile=" + mobile
                        )
                    );
        }
        public static Dictionary<String, String> get备注图(String orderId)
        {
            return
                FunctionHelper.JsonDeserialization<Dictionary<String, String>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/image/getMemoImagePath?orderId=" + orderId
                        )
                    );
        }
        public static StyleCategoryDTO get根据styleId取款式大类别(String styleId)
        {
            return
                FunctionHelper.JsonDeserialization<StyleCategoryDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/style/getCategoryByStyleId?styleId=" + styleId
                        )
                    );
        }
        public static StyleCategoryDTO getCategoryByBarcode(String barcode)
        {
            return
                FunctionHelper.JsonDeserialization<StyleCategoryDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/sale_style/getCategoryByBarcode?barcode=" + barcode
                        )
                    );
        }
        public static StyleCategoryDTO getCategoryByStyleName(String styleName)
        {
            return
                FunctionHelper.JsonDeserialization<StyleCategoryDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/sale_style/getCategoryByStyleName?styleName=" + styleName
                        )
                    );
        }
        /// <summary>
        /// 根据款式类别code去款式类别
        /// </summary>
        /// <param name="styleCategoryCd"></param>
        /// <returns></returns>
        public static StyleCategoryDTO get根据StyleCategoryCd取款式大类别(String styleCategoryCd)
        {
            return
                FunctionHelper.JsonDeserialization<StyleCategoryDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/style/getStyleCategoryByCode?code=" + styleCategoryCd
                        )
                    );
        }
        public static String post上传标准版(string refStyleId, OpenFileDialog ofd)
        {
            return
                FileService.UploadRequest(
                        URL.接口url + "/pmc/uploadCADFileByRefStyleId?refStyleId=" + refStyleId,
                        ofd.FileName,
                        Path.GetFileName(ofd.FileName),
                        "multipartFile"
                        );
        }
        public static String post上传个人版(string customerId, String refStyleId, OpenFileDialog ofd)
        {
            return
                FileService.UploadRequest(
                        URL.接口url + "/pmc/uploadCADFileByCustomerAndRefStyleId?customId=" + customerId + "&refStyleId=" + refStyleId,
                        ofd.FileName,
                        Path.GetFileName(ofd.FileName),
                        "multipartFile"
                        );
        }
        public static DTO标准版 get是否上传标准版(string refStyleId)
        {
            return
                FunctionHelper.JsonDeserialization<DTO标准版>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getCadFilePath?refStyleId=" + refStyleId
                        )
                    );
        }
        public static DTO标准版 get是否上传个人版(string refStyleId, String customerId)
        {
            return
                FunctionHelper.JsonDeserialization<DTO标准版>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getCustomerCadFilePath?customId=" + customerId + "&refStyleId=" + refStyleId
                        )
                    );
        }
        public static OrderCommitDTO返回 get订单预览By批号(String batchNo)
        {
            return
                FunctionHelper.JsonDeserialization<OrderCommitDTO返回>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getOrderCacheByOrderId?batchNo=" + batchNo
                        )
                    );
        }
        
        /// <summary>
        /// 订单更新辅料
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="stockModify"></param>
        /// <param name="styleAccessoryDTOs"></param>
        /// <returns></returns>
        public static Boolean post修改辅料(String orderId, Boolean stockModify, List<StyleAccessoryDTO> styleAccessoryDTOs)
        {
            try
            {
                return
                    FunctionHelper.JsonDeserialization<Boolean>(
                        RestCall.PostHttp(
                            URL.接口url + "/barcode/updateOrderCommitStyleAccessory?orderId=" + orderId + "&stockModify=" + stockModify,
                            FunctionHelper.JsonSerialization(styleAccessoryDTOs)
                        )
                    );
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// get刺绣相关信息：位置、颜色、字体、大小
        /// </summary>
        /// <param name="itemCd"></param>
        /// <returns></returns>
        public static List<DTO刺绣> get刺绣相关信息(String itemCd)
        {
            try
            {
                List<DTO刺绣> dTOs =
                    FunctionHelper.JsonDeserialization<List<DTO刺绣>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/barcode/getDesignOption?itemCd=" + itemCd
                        )
                    );//.GetRange(0,2);

                return dTOs;
            }
            catch
            {
                return new List<DTO刺绣>();
            }
        }
        /// <summary>
        /// SSHIRT取刺绣设计点
        /// </summary>
        /// <param name="itemCd"></param>
        /// <returns></returns>
        public static List<DTO刺绣> get4SMCDesignOptionSSHIRT(String itemCd)
        {
            try
            {
                List<DTO刺绣> dTOs =
                    FunctionHelper.JsonDeserialization<List<DTO刺绣>>(
                        RestCall.httpGetMethod(
                            URL.接口url + "/barcode/get4SMCDesignOptionSSHIRT?itemCd=" + itemCd
                        )
                    );//.GetRange(0,2);

                return dTOs;
            }
            catch
            {
                return new List<DTO刺绣>();
            }
        }
        
        /// <summary>
        /// 根据水洗标查询批号
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        public static String getBatchNoByBarcode(String barcode)
        {
            try
            {
                return
                    RestCall.httpGetMethod(
                        URL.接口url + "/barcode/getBatchNoByBarcode?barcode=" + barcode);
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// 已下单变更尺寸
        /// </summary>
        /// <param name="orderId"></param>
        /// <param name="styleId"></param>
        /// <param name="sessionId"></param>
        /// <param name="measureItemDTO"></param>
        /// <returns></returns>
        public static MeasureItemDTO saveMeasureItemByOrderId(String orderId, String styleId,String sessionId, MeasureItemDTO measureItemDTO)
        {
            return
                FunctionHelper.JsonDeserialization<MeasureItemDTO>(
                    RestCall.PostHttp(URL.接口url + "/style/saveMeasureItemByOrderId?orderId=" + orderId +
                        "&styleId=" + styleId +
                        "&sessionId=" + sessionId,
                        FunctionHelper.JsonSerialization(measureItemDTO)
                        )
                    );
        }
    }
    #region 审版文件
    public class DTO标准版
    {
        public Boolean existed { get; set; }
        public String filePath { get; set; }
        public DTO标准版()
        {

        }
    }
    #endregion

    #region 刺绣
    public class DTO刺绣
    {
        public int designId { get; set; }//
        public String styleCategoryCd { get; set; }//
        public String itemCategoryCd { get; set; }//
        public String itemCd { get; set; }//
        public String itemValue { get; set; }//
        public int itemSort { get; set; }//
        public String itemNameCn { get; set; }//
        public String itemShortNameCn { get; set; }//
        public String itemNameEn { get; set; }//
        public String itemShortNameEn { get; set; }//
        public String itemNameJp { get; set; }//
        public String itemShortNameJp { get; set; }//
        public Double itemCost { get; set; }//
        public Double itemCostMtm { get; set; }//
        public Double itemUnitCost { get; set; }//
        public int itemNetSort { get; set; }//
        public int itemCutParts { get; set; }//
        public int fileId { get; set; }//
        public int havetoFlag { get; set; }//
        public String remarks { get; set; }//
        public int enableFlag { get; set; }//
        public int deleteFlag { get; set; }//
        public int version { get; set; }//
        public DateTime createDate { get; set; }//
        public DateTime updateDate { get; set; }//
        public int createUser { get; set; }//
        public int updateUser { get; set; }//
        public DTO刺绣()
        {

        }
    }
    #endregion

    #region 运维接口DTO:OrderCommitDTO返回 及DTO里的dto
    public class OrderCommitDTO返回
    {
        public String id { get; set; }
        //销售渠道信息
        public String salesType { get; set; }  //  销售方式    
        public String salesChannel { get; set; }   //  销售渠道
        //样衣信息
        public String refBarcode { get; set; }//参考成衣码
        public String saleInventoryId { get; set; }//货号主键
        //客户返单信息
        public String refOrderId { get; set; }  //  客户返单id
        public String refOrderNo { get; set; }  //  客户返单号
        //客户信息                                         
        public String customerId { get; set; }
        public String customerName { get; set; }
        public String consignee { get; set; }//收货人姓名
        public String mobile { get; set; }
        public String addressId { get; set; }
        public String addressProvince { get; set; }//省
        public String addressCity { get; set; }//市
        public String addressDistrict { get; set; }//区
        public String addressDetail { get; set; }//详细地址
        public String zipCode { get; set; }//邮编
        public String customerCountId { get; set; }//客户量体id
        public List<CustomerFitRDTO量体值> customerFitRDTOS { get; set; } = new List<CustomerFitRDTO量体值>();//客户量体信息
        //门店信息                                                            
        public String shopId { get; set; }
        public String shopName { get; set; }
        public String styleId { get; set; }
        //订单信息
        public String orderNo { get; set; }//订单号
        public Double orderNumber { get; set; }//订单数量
        public DateTime orderDate { get; set; }//订单时间
        //款式信息
        public String styleSizeCd { get; set; }//尺码
        public String styleNameCn { get; set; }//款式名称
        public String styleYear { get; set; }//款式年份
        public String styleSeason { get; set; }//款式季节
        public String refStyleId { get; set; }//参考款id
        //面料信息
        public String styleFabricId { get; set; }//面料id
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String materialColor { get; set; }//面料颜色
        public String composition { get; set; }//面料成分
        public String density { get; set; }  //  纱织密度
        public String weight { get; set; }  //  克重
        public String width { get; set; }    //  幅宽
        public String thick { get; set; }    //  厚度
        public String elastic { get; set; }    //  弹力
        public String feature { get; set; }    //  面料特性注意
        public String continuity { get; set; }    //  延续性
        public String uasge { get; set; }    //  用途
        public String inspectionResults { get; set; }    //  验料结果
        public String color { get; set; }    //  颜色
        public String season { get; set; }    //  季节
        public String style { get; set; }    //  风格
        public String arrangementMethod { get; set; }    //  整理方式

        public String stylePublishCategoryCd { get; set; }
        public String styleCategoryCd { get; set; }
        public String styleFitCd { get; set; }
        public String styleSizeGroupCd { get; set; }
        public String styleDressCategory { get; set; }
        public String styleDesignType { get; set; }
        public String orderType { get; set; }
        public String remarks { get; set; }//备注
        public String styleMakeType { get; set; }//制作工艺
        public List<StyleAccessoryDTO> styleAccessoryDTOs { get; set; } = new List<StyleAccessoryDTO>();//新的辅料
        public StyleAccessoryItemsDTO styleAccessoryItemsDTO { get; set; } = new StyleAccessoryItemsDTO();//辅料
        public String saveStyleAccessoryItemsDTO { get; set; }//Json辅料保存
        public String sessionId { get; set; }   //  尺寸session id
        public List<MeasureItemDTO> measureItemDTOS { get; set; } = new List<MeasureItemDTO>();  //  尺寸表
        public String kashiyamaOrderNo { get; set; }
        public String kashiyamaShopCd { get; set; }
        public String fromId { get; set; }  //样品下单FormId
        public List<DTODesignPoints设计点> dtoDesignPoints { get; set; } = new List<DTODesignPoints设计点>(); //设计点
        public DtoSize dtoSize { get; set; } = new DtoSize();//尺寸
        public String orderId { get; set; }
        public Double price { get; set; }   //  建议零售价
        public Double retailPrice { get; set; }//  零售价
        public String saleConfirmId { get; set; }  //  销售确认单ID，定制下单传
        public String storeId { get; set; }  //  销售组织
        public String assistantId { get; set; }  //  销售员
        public OrderCommitDTO返回()
        {

        }
        /// <summary>
        /// 给orderCommit的尺寸赋值
        /// </summary>
        /// <param name="尺寸"></param>
        /// <returns></returns>
        public OrderCommitDTO返回 buildOrderCommit尺寸(DTOStyleMeasureItems 尺寸)
        {
            this.sessionId = 尺寸.sessionId;
            this.measureItemDTOS = 尺寸.measureItemDTOS;
            return this;
        }
        public OrderCommitDTO返回 build抖音价格(Double retailPrice)
        {
            this.retailPrice = retailPrice;
            return this;
        }
        public OrderCommitDTO返回(OrderDto orderDto)
        {
            this.id = orderDto.id;
            this.customerId = orderDto.customerId;
            this.customerName = orderDto.customerName;
            this.addressId = orderDto.addressId;
            this.consignee = orderDto.consignee;
            this.mobile = orderDto.mobile;
            this.addressProvince = orderDto.addressProvince;
            this.addressCity = orderDto.addressCity;
            this.addressDistrict = orderDto.addressDistrict;
            this.addressDetail = orderDto.addressDetail;
            this.zipCode = orderDto.zipCode;
            this.customerCountId = orderDto.customerCountId;
            this.shopId = orderDto.shopId;
            this.shopName = orderDto.shopName;
            this.styleId = orderDto.styleId;
            this.orderNo = orderDto.orderNo;
            this.orderNumber = orderDto.orderNumber;
            this.orderDate = orderDto.orderDate;
            this.styleSizeCd = orderDto.styleSizeCd;
            this.styleNameCn = orderDto.styleNameCn;
            this.styleYear = orderDto.styleYear;
            this.styleSeason = orderDto.styleSeason;
            this.refStyleId = orderDto.refStyleId;
            this.styleFabricId = orderDto.styleFabricId;
            this.materialNameCn = orderDto.materialNameCn;
            this.materialCode = orderDto.materialCode;
            this.materialColor = orderDto.materialColor;
            this.stylePublishCategoryCd = orderDto.stylePublishCategoryCd;
            this.styleCategoryCd = orderDto.styleCategoryCd;
            this.styleFitCd = orderDto.styleFitCd;
            this.styleSizeGroupCd = orderDto.styleSizeGroupCd;
            this.styleDressCategory = orderDto.styleDressCategory;
            this.styleDesignType = orderDto.styleDesignType;
            this.orderType = orderDto.orderType.ToString();
            this.remarks = orderDto.remarks;
            this.styleMakeType = orderDto.styleMakeType;
            this.styleAccessoryItemsDTO = orderDto.styleAccessoryItemsDTO;
            this.saveStyleAccessoryItemsDTO = orderDto.saveStyleAccessoryItemsDTO;
            this.sessionId = orderDto.sessionId;
            this.kashiyamaOrderNo = orderDto.kashiyamaOrderNo;
            this.fromId = orderDto.fromId;
            this.retailPrice = orderDto.retailPrice;
            foreach (DTODesignPoints item in orderDto.dtoDesignPoints)
            {
                this.dtoDesignPoints.Add(new DTODesignPoints设计点(item));
            }
            this.dtoSize = orderDto.dtoSize;
            this.measureItemDTOS = orderDto.measureItemDTOS;
            this.refOrderId = orderDto.refOrderId;
            this.refOrderNo = orderDto.refOrderNo;
            this.styleAccessoryDTOs = orderDto.styleAccessoryDTOs;
        }
        /// <summary>
        /// 大连坚山（森茂、开发区）下单，根据前台选择店铺传kashiyamaShopCd
        /// </summary>
        /// <param name="orderDto">orderDto</param>
        /// <param name="kashiyamaShopCd">kashiyamaShopCd在前台选择门店后赋值</param>
        public OrderCommitDTO返回(OrderDto orderDto,String kashiyamaShopCd)
        {
            this.id = orderDto.id;
            this.customerId = orderDto.customerId;
            this.customerName = orderDto.customerName;
            this.addressId = orderDto.addressId;
            this.consignee = orderDto.consignee;
            this.mobile = orderDto.mobile;
            this.addressProvince = orderDto.addressProvince;
            this.addressCity = orderDto.addressCity;
            this.addressDistrict = orderDto.addressDistrict;
            this.addressDetail = orderDto.addressDetail;
            this.zipCode = orderDto.zipCode;
            this.customerCountId = orderDto.customerCountId;
            this.shopId = orderDto.shopId;
            this.shopName = orderDto.shopName;
            this.styleId = orderDto.styleId;
            this.orderNo = orderDto.orderNo;
            this.orderNumber = orderDto.orderNumber;
            this.orderDate = orderDto.orderDate;
            this.styleSizeCd = orderDto.styleSizeCd;
            this.styleNameCn = orderDto.styleNameCn;
            this.styleYear = orderDto.styleYear;
            this.styleSeason = orderDto.styleSeason;
            this.refStyleId = orderDto.refStyleId;
            this.styleFabricId = orderDto.styleFabricId;
            this.materialNameCn = orderDto.materialNameCn;
            this.materialCode = orderDto.materialCode;
            this.materialColor = orderDto.materialColor;
            this.stylePublishCategoryCd = orderDto.stylePublishCategoryCd;
            this.styleCategoryCd = orderDto.styleCategoryCd;
            this.styleFitCd = orderDto.styleFitCd;
            this.styleSizeGroupCd = orderDto.styleSizeGroupCd;
            this.styleDressCategory = orderDto.styleDressCategory;
            this.styleDesignType = orderDto.styleDesignType;
            this.orderType = orderDto.orderType.ToString();
            this.remarks = orderDto.remarks;
            this.styleMakeType = orderDto.styleMakeType;
            this.styleAccessoryItemsDTO = orderDto.styleAccessoryItemsDTO;
            this.saveStyleAccessoryItemsDTO = orderDto.saveStyleAccessoryItemsDTO;
            this.sessionId = orderDto.sessionId;
            this.kashiyamaOrderNo = orderDto.kashiyamaOrderNo;
            this.kashiyamaShopCd = kashiyamaShopCd;
            this.fromId = orderDto.fromId;
            foreach (DTODesignPoints item in orderDto.dtoDesignPoints)
            {
                this.dtoDesignPoints.Add(new DTODesignPoints设计点(item));
            }
            this.dtoSize = orderDto.dtoSize;
            this.measureItemDTOS = orderDto.measureItemDTOS;
            this.refOrderId = orderDto.refOrderId;
            this.refOrderNo = orderDto.refOrderNo;
            this.styleAccessoryDTOs = orderDto.styleAccessoryDTOs;
        }
        /// <summary>
        /// 上海坚山下单，判断是否邮寄门店、客户地址，如果邮寄门店kashiyamaShopCd = KASHIYAMA_SH
        /// </summary>
        /// <param name="orderDto">orderDto</param>
        /// <param name="expressToStore">根据前台选择传布尔值，如果为true则邮寄门店，并给kashiyamaShopCd赋值；如果为false则邮寄客户地址，kashiyamaShopCd不赋值</param>
        public OrderCommitDTO返回(OrderDto orderDto, Boolean expressToStore)
        {
            this.id = orderDto.id;
            this.customerId = orderDto.customerId;
            this.customerName = orderDto.customerName;
            this.addressId = orderDto.addressId;
            this.consignee = orderDto.consignee;
            this.mobile = orderDto.mobile;
            this.addressProvince = orderDto.addressProvince;
            this.addressCity = orderDto.addressCity;
            this.addressDistrict = orderDto.addressDistrict;
            this.addressDetail = orderDto.addressDetail;
            this.zipCode = orderDto.zipCode;
            this.customerCountId = orderDto.customerCountId;
            this.shopId = orderDto.shopId;
            this.shopName = orderDto.shopName;
            this.styleId = orderDto.styleId;
            this.orderNo = orderDto.orderNo;
            this.orderNumber = orderDto.orderNumber;
            this.orderDate = orderDto.orderDate;
            this.styleSizeCd = orderDto.styleSizeCd;
            this.styleNameCn = orderDto.styleNameCn;
            this.styleYear = orderDto.styleYear;
            this.styleSeason = orderDto.styleSeason;
            this.refStyleId = orderDto.refStyleId;
            this.styleFabricId = orderDto.styleFabricId;
            this.materialNameCn = orderDto.materialNameCn;
            this.materialCode = orderDto.materialCode;
            this.materialColor = orderDto.materialColor;
            this.stylePublishCategoryCd = orderDto.stylePublishCategoryCd;
            this.styleCategoryCd = orderDto.styleCategoryCd;
            this.styleFitCd = orderDto.styleFitCd;
            this.styleSizeGroupCd = orderDto.styleSizeGroupCd;
            this.styleDressCategory = orderDto.styleDressCategory;
            this.styleDesignType = orderDto.styleDesignType;
            this.orderType = orderDto.orderType.ToString();
            this.remarks = orderDto.remarks;
            this.styleMakeType = orderDto.styleMakeType;
            this.styleAccessoryItemsDTO = orderDto.styleAccessoryItemsDTO;
            this.saveStyleAccessoryItemsDTO = orderDto.saveStyleAccessoryItemsDTO;
            this.sessionId = orderDto.sessionId;
            this.kashiyamaOrderNo = orderDto.kashiyamaOrderNo;
            //根据布尔值判断是否邮寄到门店
            if (expressToStore)
            {
                this.kashiyamaShopCd = "KASHIYAMA_SH";
            }
            this.fromId = orderDto.fromId;
            foreach (DTODesignPoints item in orderDto.dtoDesignPoints)
            {
                this.dtoDesignPoints.Add(new DTODesignPoints设计点(item));
            }
            this.dtoSize = orderDto.dtoSize;
            this.measureItemDTOS = orderDto.measureItemDTOS;
            this.refOrderId = orderDto.refOrderId;
            this.refOrderNo = orderDto.refOrderNo;
            this.styleAccessoryDTOs = orderDto.styleAccessoryDTOs;
        }
        public OrderCommitDTO返回 build给客户赋值(DTO选择用户 DTO选择用户)
        {
            this.customerId = DTO选择用户.customerId.ToString();
            this.customerCountId = DTO选择用户.customerCountId.ToString();
            this.customerName = DTO选择用户.customerName;
            this.addressId = DTO选择用户.addressId.ToString();
            return this;
        }
        public OrderCommitDTO返回 build给客户赋值新(CustomerPDTO customerPDTD)
        {
            this.customerName = customerPDTD.customerName;
            this.mobile = customerPDTD.mobile;
            this.consignee = customerPDTD.customerName;
            this.addressProvince = customerPDTD.addressProvince;
            this.addressCity = customerPDTD.addressCity;
            this.addressDistrict = customerPDTD.addressDistrict;
            this.addressDetail = customerPDTD.addressDetail;
            this.zipCode = customerPDTD.zipCode;
            return this;
        }
        public OrderCommitDTO返回 build给经销商赋值(DTO客户店铺 dto客户店铺)
        {
            this.customerId = dto客户店铺.customerId.ToString();
            this.customerCountId = Convert.ToString(1);
            this.customerName = dto客户店铺.customerName;
            this.addressId = dto客户店铺.addressId.ToString();
            return this;
        }
        public OrderCommitDTO返回 build给销售渠道赋值(String salesType, String salesChannel)
        {
            this.salesType = salesType;
            this.salesChannel = salesChannel;
            return this;
        }
        public OrderCommitDTO返回 build给款式信息赋值(
            String refBarcode,
            String styleNameCn,
            String materialCode,
            String materialNameCn,
            String composition,
            String price)
        {
            this.refBarcode = refBarcode;
            this.styleNameCn = styleNameCn;
            this.materialCode = materialCode;
            this.materialNameCn = materialNameCn;
            this.composition = composition;
            this.price = double.Parse(price);
            return this;
        }
    }
    public class CustomerFitRDTO量体值 //量体值
    {
        public String itemCd { get; set; }//人尺寸CD
        public String itemValue { get; set; }//人尺寸VALUE
        public String fitValue { get; set; }//人尺寸
        public String fitCountId { get; set; }//CountId
        public String propertyNameCn { get; set; }//人尺寸类别名称
        public String remarks { get; set; }//衣服尺寸VALUE
        public String itemNameCn { get; set; }//人量体名称
        public CustomerFitRDTO量体值()
        {

        }
        public CustomerFitRDTO量体值(string itemValue, string fitValue, string propertyNameCn, string remarks, string itemNameCn)
        {
            this.itemCd = "SHIRT_FITMT004";
            this.itemValue = itemValue;
            this.fitValue = fitValue;
            this.propertyNameCn = propertyNameCn;
            this.remarks = remarks;
            this.itemNameCn = itemNameCn;
        }
    }

    public class DTODesignPoints设计点 //设计点
    {
        public String itemTypeNameCn { get; set; }
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public String optionValue { get; set; }
        public String enableFlag { get; set; }
        public String deleteFlag { get; set; }
        public String defaultValue { get; set; }

        //  设计点名称
        public String name { get; set; }
        public String styleId { get; set; }//款式id
        public DTODesignPoints设计点()
        {

        }
        public DTODesignPoints设计点 buildOptionName(String itemCd, String itemValue, String optionValue, String name)
        {
            this.itemCd = itemCd;
            this.itemValue = itemValue;
            this.optionValue = optionValue;
            this.name = name;
            return this;
        }

        public DTODesignPoints设计点(DTODesignPoints dTODesignPoints)
        {
            this.itemTypeNameCn = dTODesignPoints.itemTypeNameCn;
            this.itemCd = dTODesignPoints.itemCd;
            this.itemValue = dTODesignPoints.itemValue;
            this.optionValue = dTODesignPoints.optionValue;
            this.enableFlag = dTODesignPoints.enableFlag;
            this.deleteFlag = dTODesignPoints.deleteFlag;
            this.defaultValue = dTODesignPoints.defaultValue;
            this.name = dTODesignPoints.name;
            this.styleId = dTODesignPoints.styleId;
        }
    }
    public class DtoSize尺寸  //尺寸
    {
        public String styleId { get; set; }
        public String itemCd { get; set; }
        public String itemValue { get; set; }
        public String fitValue { get; set; }
        public String fmValue { get; set; }
        public String inValue { get; set; }
        public String outValue { get; set; }
        public String status { get; set; }
        public String deleteFlag { get; set; }
        public String customerCountId { get; set; }
        public String phaseCd { get; set; }
        public String version { get; set; }
        public String createUser { get; set; }
        public DtoSize尺寸()
        {

        }
    }
    #endregion

    #region 页面显示的转换DTO
    public class 面料DTOs
    {
        public String styleFabricId { get; set; }//面料id
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String materialColor { get; set; }//面料颜色
        public String composition { get; set; }//面料成分
        public String width { get; set; } //幅宽
        public Image picture { get; set; }
        public 面料DTOs(OrderCommitDTO返回 OrderCommitDTO返回)
        {
            this.styleFabricId = OrderCommitDTO返回.styleFabricId;
            this.materialNameCn = OrderCommitDTO返回.materialNameCn;
            this.materialCode = OrderCommitDTO返回.materialCode;
            this.materialColor = OrderCommitDTO返回.materialColor;
            this.composition = OrderCommitDTO返回.composition;
            this.width = OrderCommitDTO返回.width;
            try
            {
                this.picture
                    = FileService.GetImageByUrl(
                        URL.图片url + URL.面料图片路径 + RestCall.httpGetMethod(
                            URL.接口url + "/image/getImagePath?materialCode=" + OrderCommitDTO返回.materialCode
                            )
                        );
            }
            catch
            {
                this.picture = FunctionHelper.getSSHIRT();
            }
        }
    }
    public class 款式DTOs
    {
        public String stylePublishCategoryCd { get; set; }  //款式大类别
        public String styleNameCn { get; set; }//款式名称
        public String styleYear { get; set; }//款式年份
        public String styleSeason { get; set; }//款式季节
        public String refStyleId { get; set; }//参考款id
        public Image picture { get; set; }
        public 款式DTOs(OrderCommitDTO返回 OrderCommitDTO返回)
        {
            this.stylePublishCategoryCd = get类别(OrderCommitDTO返回.stylePublishCategoryCd);
            this.styleNameCn = OrderCommitDTO返回.styleNameCn;
            this.styleYear = OrderCommitDTO返回.styleYear;
            this.styleSeason = get季节(OrderCommitDTO返回.styleSeason);
            this.refStyleId = OrderCommitDTO返回.refStyleId;
            try
            {
                this.picture
                    = FileService.GetImageByUrl(
                        URL.图片url + URL.款式图片路径 + RestCall.httpGetMethod(
                            URL.接口url + "/image/getStyleImagePathByStyleId?styleId=" + OrderCommitDTO返回.refStyleId
                            )
                        );
            }
            catch
            {
                this.picture = FunctionHelper.getSSHIRT();
            }
        }
        private static String get季节(String styleSeason)
        {
            if ("SEASON-SEASON_10".Equals(styleSeason))
            {
                return "春季";
            }
            if ("SEASON-SEASON_20".Equals(styleSeason))
            {
                return "秋季";
            }
            return styleSeason;
        }
        private static String get类别(String stylePublishCategoryCd)
        {
            if ("PUBLISH_STYLE_CATEGORY-WShirt".Equals(stylePublishCategoryCd))
            {
                return "女衬衫";
            }
            if ("PUBLISH_STYLE_CATEGORY-MShirt".Equals(stylePublishCategoryCd))
            {
                return "男衬衫";
            }
            return stylePublishCategoryCd;
        }
    }
    public class 备注DTOs
    {
        public String id { get; set; }//id
        public Image picture { get; set; }//图片
        public String name { get; set; }//名称
        public 备注DTOs(KeyValuePair<String, String> keyValuePair)
        {
            this.id = keyValuePair.Key;
            this.name = keyValuePair.Value;
            try
            {
                this.picture = FileService.GetImageByUrl(URL.图片url + URL.备注图片路径 + this.name);
            }
            catch { }
        }

        public 备注DTOs(string id, Image picture, string name)
        {
            this.id = id;
            this.picture = picture;
            this.name = name;
        }
    }
    #endregion

    public class DTO客户店铺
    {
        public String customerName { get; set; }  //客户名
        public String addressId { get; set; }
        public String customerId { get; set; }
        public String consignee { get; set; }  //收件人姓名
        public String addressProvinceCd { get; set; }
        public String addressCityCd { get; set; }
        public String addressDistrict { get; set; }
        public String addressDetail { get; set; }
        public String zipCode { get; set; }
        public String mobile { get; set; }
        public Boolean defaultAddrFlagBoolean { get; set; }
        public int defaultAddrFlag { get; set; }
        public DTO客户店铺()
        {

        }
    }
}
